/**
 * 逐步求和得到正数的最小值
 *
 * @USER: Administrator
 * @DATE: 2024/9/15 下午1:05
 * @VERSION: 1.0.0
 */
public class LC1413 {
    public int minStartValue(int[] nums) {
        int minSum = nums[0];
        int sum = 0;
        for (int num : nums) {
            sum += num;
            if (num < 0 && sum < minSum) {
                minSum = sum;
            }
        }
        return Math.max(1,1-minSum);
    }
}
